const service = require("../services/user");
const user = {
  submit: async (req, res) => {
    const result = await service.addUser(req.body);
    result
      .save()
      .then(() => {
        res.send({
          success: true,
          data: null,
          code: 200,
          message: "提交成功",
        });
      })
      .catch(() => {
        res.send({
          success: false,
          data: null,
          message: "提交成功",
          code: 500,
        });
      });
  },
  findList: async (req, res) => {
    try {
      const result = await service.findList(req.body);
      res.send({
        success: true,
        data: result,
        code: 200,
        message: "登录成功",
      });
    } catch {
      res.send({
        success: false,
        data: null,
        code: 500,
        message: "服务器错误",
      });
    }
  },
};
module.exports = user;
